import 'package:flutter/material.dart';

Map<String, dynamic> overlayMap = {};
OverlayState? _overlayState;
List<OverlayEntry> _overlayList = [];

OverlayEntry show(
    {required BuildContext context,
    required String key,
    required Widget child,
    bool isShowTop = true}) {
  if (_overlayState == null) {
    Overlay.of(context);
  }
  _overlayState = Overlay.of(context);
  _overlayList.add(
      OverlayEntry(opaque: false, builder: (BuildContext context) => child));
  _overlayState?.insert(_overlayList.last);
  return _overlayList.last;
}

remove() {
  _overlayList.last.remove();
  _overlayList.removeLast();
}
